﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using Sustainalytics.ClientDW.Synchronization.SyncReferenceUniv.ReferenceUniverseLogic;
using Sustainalytics.SharedEntities.Corporate;
using Xunit;
using Xunit.Abstractions;

namespace Sustainalytics.ClientDW.Synchronization.SyncReferenceUniv.Tests
{
    public class ReferenceUniverseCommandTests: ReferenceUniverseBaseTests
    {
        readonly ReferenceUniverseCommand referenceUniverseCommand;
        public ReferenceUniverseCommandTests(ITestOutputHelper output) : base(output)
        {
            referenceUniverseCommand = SimpleInjectorContainer.GetInstance<ReferenceUniverseCommand>();
        }

        [Fact]
        public async Task DeleteRecordsAsync_Should_DeleteRecords()
        {
            var res = await referenceUniverseCommand.DeleteRecordsAsync();
            Assert.NotNull(res.DeletedCount);
        }

        [Fact]
        public async Task InsertRecordsAsync_Should_InsertRecords()
        {
            var referenceUniverse = new ReferenceUniverse()
            {
                Id = Guid.NewGuid(),
                Name = "Ionut Test",
                Companies = new List<ReferenceUniverseCompany>()
                {
                    new ReferenceUniverseCompany()
                    {
                        CompanyId = Guid.NewGuid(),
                        CompanyName = "Test 123",
                        CapitalIqId = 111111
                    }
                }
            };

            await referenceUniverseCommand.InsertRecordsAsync(new List<ReferenceUniverse>(){ referenceUniverse });
        }
    }
}
